<template>
  <a-card :bordered="false" class="card-area">
    <!-- 查询区域 11111-->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" :label-col="labelCol" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="设备号">
              <a-input placeholder="请输入设备号" v-model="queryParam.deviceId"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="设备名称">
              <a-input placeholder="请输入设备名称" v-model="queryParam.deviceName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="5" :sm="8">
            <a-form-item label="设备状态">
              <j-dict-select-tag v-model='queryParam.auditStatus' dictCode='start_stop_status' placeholder='请选择设备状态' />
            </a-form-item>
          </a-col>
          <a-col :md="5" :sm="8">
            <a-form-item label="设备类型">
              <j-dict-select-tag v-model='queryParam.deviceType' dictCode='device_type' placeholder='请选择设备类型' />
            </a-form-item>
          </a-col>
          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
           <a-col :md="6" :sm="24">
               <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
               <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
           </a-col>
        </span>
        </a-row>
      </a-form>
    </div>

    <!-- 操作按钮区域 -->
    <div class="table-operator">
     <a-button @click='handleAdd()' type='primary' icon='plus'>绑定客户设备</a-button>
    </div>

    <!-- table区域-begin -->
    <div>


      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <span slot="action" slot-scope="text, record">
          <a @click="handlePost({id:record.id},'/store/ter/device/info/changeStatus','设备是否设为禁用状态')" v-if="'1'==record.auditStatus">设为禁用</a>
          <a @click="handlePost({id:record.id},'/store/ter/device/info/changeStatus','设备是否设为启用状态')" v-if="'0'==record.auditStatus">设为启用</a>
          <a-divider type="vertical" />
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)" v-if="record.isBind">
            <a>解除绑定</a>
          </a-popconfirm>
          <a @click="handleEdit(record)" v-if="!record.isBind&&record.deviceType!=3">绑定客户</a>
        </span>
      </a-table>
    </div>

    <h-device-info-modal  ref="modalForm" @ok="modalFormOk"></h-device-info-modal>
  </a-card>
</template>
<script>
import '@assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import HDeviceInfoModal from './modules/HDeviceInfoModal'
import { putAction, getAction, postAction } from '@api/manage'
import { frozenBatch } from '@api/api'

export default {
  name: 'h_device_infoList',
  mixins: [JeecgListMixin],
  components: {
    HDeviceInfoModal
  },
  data() {
    return {
      description: '设备信息管理页面',
      labelCol: { style: { width: '110px' } },
      // 表头
      columns: [
        {
          title: '设备号',
          align: 'center',
          dataIndex: 'deviceId'
        },
        {
          title: '设备名称',
          align: 'center',
          width:180,
          dataIndex: 'deviceName'
        },
        {
          title: '设备类型',
          align: 'center',
          width:150,
          dataIndex: 'deviceType_dictText'
        },
        {
          title: '设备状态',
          align: 'center',
          width:150,
          dataIndex: 'auditStatus_dictText'
        },
        {
          title: '设备通讯模式',
          align: 'center',
          width:150,
          dataIndex: 'netType'
        },
        {
          title: '设备所属客户',
          align: 'center',
          width:150,
          dataIndex: 'patientName'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          width:180,
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        list: '/store/ter/device/info/list',
        delete: '/store/ter/device/info/delete',
        deleteBatch: '/store/ter/device/info/deleteBatch',
      }
    }
  },
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {}
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>